<#import "../macro/components.ftl" as components/>
<#include "../macro/layout_default.ftl"/>

<@body>
<script src="/misc/app/js/pbc_list.js"></script>
</@body>
<@layout_default>
<div class="box">
    <div class="box-header with-border">
        <span class="pull-right text-muted">共 ${pbcList.resultTotal} 条记录</span>
        <form class="form-inline" action="/pbc">
            <div class="input-group">
                <div class="input-group-addon">关键词</div>
                <input type="text" class="form-control" style="width: 260px" name="pcount" value="${pcount!}" placeholder="输入规格数量"/>
            </div>
            <div class="input-group">
                <div class="input-group-addon">状态</div>
                <select class="form-control" name="state">
                    <option value="">全部</option>
                    <option value="1" ${(state?exists && state == 1)?string("selected","")}>正常</option>
                    <option value="2" ${(state?exists && state == 2)?string("selected","")}>停用</option>
                </select>
            </div>

            <button type="submit" class="btn btn-warning"><i class="fa fa-search"></i> 查询</button>
            <button type="button" id="search_reset" class="btn btn-warning"><i class="fa"></i> 重置</button>
            <button type="button" class="btn btn-default" name="btn_new_pbc" data-toggle="modal" data-target="#md_new_pbc"><i class="fa fa-plus"></i> 新增规格</button>
        </form>
        <form class="form-inline hide">
            <input class="form-control"/>
            <input type="email" class="form-control"/>
            <button type="submit" class="btn btn-default">Send invitation</button>
        </form>
    </div>
    <!-- /.box-header -->
    <div class="box-body">
        <table class="table table-striped table-hover">
            <tr>
                <th>ID</th>
                <th>规格</th>
                <th>状态</th>
                <th>录入时间</th>
                <th>录入人</th>
                <th>操作</th>
            </tr>
            <#if (pbcList.result?size > 0)>
                <#list pbcList.result as item>
                    <tr>
                        <td>${item.id}</td>
                        <td>1 × ${item.pcount}</td>
                        <td><#if item.state==1><span class="text-green">正常</span><#elseif item.state==2><span class="text-yellow">停用</span><#else><span class="text-danger">未知</span></#if></td>
                        <td>${item.createTime?string("yyyy-MM-dd")}</td>
                        <td>${item.createStaffAccount}</td>
                        <td>
                            <button type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#md_edit_pbc" data-pbc-id="${item.id}">编辑</button>
                            <#--<button type="button" class="btn btn-default btn-xs" name="btn_delete_pbc" data-pbc-id="${item.id}">删除</button>-->
                        </td>
                    </tr>
                </#list>
            <#else>
                <tr>
                    <td class="text-center text-muted" colspan="6"><i class="fa fa-info-circle"></i> 没有记录</td>
                </tr>
            </#if>
        </table>
    </div>
    <!-- /.box-body -->
    <div class="box-footer text-center">
        <@components.pagination "/pbc?pcount=${pcount!}&state=${state!}&page=$page",pbcList.page,pbcList.pageTotal/>
    </div>
</div>


<!--=========== Modals =============-->
<!-- md_new_pbc -->
<div class="modal" id="md_new_pbc" tabindex="-1">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel"><i class="fa fa-plus"></i> 新增规格</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" name="form_new_pbc">
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 每箱数量</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" placeholder="每箱数量" name="pcount"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 状态</label>
                        <div class="col-sm-10">
                            <select class="form-control" name="state">
                                <option value="1">正常</option>
                                <option value="2">停用</option>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" name="btn_save_new_pbc">保存</button>
            </div>
        </div>
    </div>
</div>
<!-- md_edit_pbc -->
<div class="modal" id="md_edit_pbc" tabindex="-1">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel"><i class="fa fa-pencil-square-o"></i> 编辑规格</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" name="form_edit_pbc">
                    <input type="hidden" name="id"/>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 每箱数量</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" placeholder="每箱数量" name="pcount"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 状态</label>
                        <div class="col-sm-10">
                            <select class="form-control" name="state">
                                <option value="1">正常</option>
                                <option value="2">停用</option>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" name="btn_save_edit_pbc">保存</button>
            </div>
        </div>
    </div>
</div>

</@layout_default>